package com.example.demo.Controller;

import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.io.File;
import java.io.FileNotFoundException;

@Controller

public class Manager {
    @RequestMapping("manager/")
    @ResponseBody
    public String index() throws FileNotFoundException {
        return ResourceUtils.getURL("classpath:").getPath().toString();
    }

    @RequestMapping(path = "manager/view",method = RequestMethod.GET)
    public String view(Model model){
        model.addAttribute("dir","file:///F:/zhengzhou/FileShareServer/target/file/");
        return "view";
    }

//    @RequestMapping(path = "view/{name}",method = RequestMethod.GET)
//    public String viewResource(Model model, @PathVariable("name") String name){
//        File file = new File("file/"+name);
//        System.out.println(name);
//        model.addAttribute("dir",String.valueOf(file.toPath()));
//        return "view";
//    }



}
